//
//  ViewController.m
//  画板录制
//
//  Created by lrj on 2023/3/4.
//

#import "ViewController.h"
#import "LRJ_PaintView.h"

@interface ViewController ()
{
    CFTimeInterval        lastTime;
}
@property (weak, nonatomic) IBOutlet UIImageView *testImageV;
@property (weak, nonatomic) IBOutlet LRJ_PaintView *myPaintView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // 画笔颜色设置，这里不做处理，传一个默认颜色，如果有需要可以自己实现一个颜色选择器
    [(LRJ_PaintView *)self.myPaintView setBrushColorWithRed:121.0 / 255.0 green:190.0 / 255.0 blue:127.0 / 255.0];
    ((LRJ_PaintView *)self.myPaintView).testImage = self.testImageV;
    
   
}

//改变画笔颜色
-(void)changBrushColor:(id)sender
{
    //自己去实现吧
    
    
}


//清除所有
- (void)eraseView
{
    /*
     参考课件！
     NSDate、CFAbsoluteTimeGetCurrent、CACurrentMedaiTime的区别？
     */
    //防止一直不停的点击清除屏幕！
    //当前设备时间 > 上一次点击时间 + 间隔时间
    if(CFAbsoluteTimeGetCurrent() > lastTime + 0.5) {
        NSLog(@"清除屏幕！");
        //清理屏幕
        [(LRJ_PaintView *)self.myPaintView erase];
        //保存这次时间到 lastTime
        lastTime = CFAbsoluteTimeGetCurrent();
    }
}

- (IBAction)clearColorAction:(UIButton *)sender {
    [(LRJ_PaintView *)self.myPaintView clearColor];
    
    
    
}
- (IBAction)getBackColor:(UIButton *)sender {
    
    [self.myPaintView setBrushColorWithRed:255.0 / 255.0 green:255.0 / 255.0 blue:255.0 / 255.0];
    
    
}


@end
